class Describe{
    constructor(id,teaname,teatype,teaimg,teaprice,teadescribe){
        this.id=id;
        this.teaname=teaname;
        this.teatype=teatype;
        this.teaimg=teaimg;
        this.teaprice=teaprice;
        this.teadescribe=teadescribe;   
    }
}

Mock.mock("/js/茶叶回显","post",function(){
    //获取本地存储里面的所有数据
   let teaString=localStorage.Tea;
        return teaString;
})

Mock.mock("/js/分类显示","post",function(obj){
    debugger
    //把body属性值转为对象
    let typeobj=JSON.parse(obj.body);
    let type=typeobj.teatype;
    //获取本地存储
    let teaString=localStorage.Tea;
    let teaObjArr=JSON.parse(teaString);
    let s = "";  
    for(var i=0;i<teaObjArr.length;i++){
        if(type==teaObjArr[i].teatype){
            s+=`<div class="part" onclick="describe(${teaObjArr[i].id})">`
            s+=`<div class="area">`
            s+=`<div class="imgdiv">`
            s+=`<img src="../img/tea-img/${teaObjArr[i].teaimg}" alt="">`
            s+=`</div>`
            s+=`<div class="font1">${teaObjArr[i].teaname}</div>`
            s+=`<div class="bigbox">`
            s+=`<div class="box1"></div>`
            s+=`<div class="box2"></div>`
            s+=`</div>`
            s+=`<div class="font2">￥${teaObjArr[i].teaprice}</div>`
            s+=`<div class="box3">`
            s+=`<a href="">→</a>`
            s+=`</div>`
            s+=`</div>`
            s+=`</div>`
        }
    }
    return s;
})

function describe(id){
    let teaString=localStorage.Tea;
    let teaArr=JSON.parse(teaString);
    for(let i=0;i<teaArr.length;i++){
        if(id==teaArr[i].id){
            let newtea=new Describe(teaArr[i].id,teaArr[i].teaname,teaArr[i].teatype,teaArr[i].teaimg,teaArr[i].teaprice,teaArr[i].teadescribe);
            let arr=[newtea];
            localStorage.Describe=JSON.stringify(arr);
        }
    }
    location.href="茶叶简介.html";
}